﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="A_List.aspx.cs" Inherits="QD.Weijie.Web.Passport.A_List" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="nocache" content="no-cache">
    <title>客户列表-管理中心</title>
    <link href="css/css.css" rel="stylesheet" type="text/css" />
    <link href="css/base.css" rel="stylesheet" type="text/css" />
    <script src="js/jquery-1.7.1.js" type="text/javascript"></script>
    <script src="js/common.js" type="text/javascript"></script>
    <script src="js/Pager.js" type="text/javascript"></script>
    <script src="js/Toast.js" type="text/javascript"></script>
    <style type="text/css">
    .content{margin-left: auto;margin-right: auto;margin-top: 10px;overflow: hidden;}
    .contenthead{width: 940px;height: 60px;margin-left: auto;margin-right: auto;margin-top: 6px;
    overflow: hidden;background-color: #E4E4E4;padding-left: 30px;}
    .menu0{padding-top: 15px;}
    #menu0 ul{margin: 0px;padding: 0px;list-style: none;margin-left: -5px;}
    #menu0 ul li{margin: 0px;padding: 0px;list-style: none;margin-left: -5px;}
    #menu0 ul{height: 45px;border-bottom: 1px solid #F37F12;}
    #menu0 ul li{background-color: #EDEDED;width: 175px;font-size: 16px;height: 44px;border: 1px solid #ccc;border-bottom: none;text-align: center;line-height: 42px;float: left;color: #2C2B30;font-weight: 800;margin-left: 5px;cursor: pointer;}
    #menu0 ul li.hover{height: 45px;background-color: white;color: #F47D09;border: 1px solid #F37F12;border-bottom: none;cursor: pointer;}
    .menu0 .reg{padding: 0 20px 0 20px;line-height: 40px;margin-top: 0px;font-size: 20px;color: red;text-decoration: none;cursor: pointer;display: block;font-weight: 100;border: 1px solid #ccc;border-radius: 5px 5px 5px 5px;}
    .contentnva{padding-left: 30px;margin-top: 20px;padding-bottom: 10px;border-bottom: 1px solid #ccc;color: #A7A7A7;font-size: 14px;}
    .contentbody{width: 960px;margin-left: auto;margin-right: auto;overflow: hidden;}
    .contentul{width: 970px;overflow: hidden;margin-left: auto;margin-right: auto;}
    #user_ad{margin-top: 13px;color: #333;font-size: 16px;font-weight: 100;}
    .query{border: 1px solid #EDEDED;width: 970px;margin-left: auto;margin-right: auto;margin-top: 15px;}
    .contentquerytab{border-collapse: collapse;}
    .contentquerytab tr{width: 960px;height: 64px;text-align: center;}
    .tabs1{border-collapse: collapse;width: 970px;color: #696969;text-align: center;font-size: 16px;}
    .tabs1 td, th{border: 1px solid #EDEDED;}
    .tabs1 td{line-height: 35px;}
    #contenttabs{width: 970px;margin-left: auto;margin-right: auto;overflow: hidden;margin-top: 10px;margin-bottom: 20px;}
    </style>
    <script type="text/javascript">
        var pager = new Pager();
        var old1, old2, old3;
        $(document).ready(function () {
            GetList(1);
        });

        var tag_cerent = "tab1";
        function tab_ck(tag) {
            tag_cerent = tag;
            $("#tab1").addClass("none");
            $("#tab2").addClass("none");
            $("#tab3").addClass("none");
            $("#" + tag).removeClass("none");
            GetList(1);
        }

        //显示列表
        function GetList(page) {
            if (wait.isShow) return;
            var param = { sitename: $("#siteName").val(), username: $("#userName").val(), page: page };
            if (old1 == param.sitename && old2 == param.username && old3 == param.page) return;

            $.get("ajax/agent.ashx?getlist", param, function (json) {
                old1 = param.sitename;
                old2 = param.username;
                old3 = param.page;
                var tbody = $("#tbody_" + tag_cerent);
                $(tbody).empty();
                $(".pager_style").removeClass("none");
                if (json.code != 0) {
                    $(tbody).append("<tr><td colspan=6>" + json.msg + "</td></tr>");
                    $(".pager_style").addClass("none");
                    return;
                }
                var list = json.item.table;

                if (list.length == 0) {
                    $(tbody).append("<tr><td colspan=6>没有记录</td></tr>");
                }
                for (var i in list) {
                    var endtime = "";
                    var gname = list[i].groupname;
                    var state = list[i].state == true ? "1" : "0";
                    if (gname == null || gname == "0")
                        gname = "";

                    if (list[i].end_date != null)
                        endtime = list[i].date.substring(0, list[i].date.indexOf("T")) + "<br />至<br />" + list[i].end_date.substring(0, list[i].end_date.indexOf("T"));

                    $(tbody).append("<tr><td>" + list[i].id + "</td>"+
                    "<td style='text-align:left'>" + list[i].nick_name +
                    "<div id='customerinformation'>帐号: " +list[i].name+ "</div>" +
                    "</td>" +
                    "<td style='text-align:left'>手机: " + list[i].phone + "<br/>Q Q: " + (list[i].qq == null ? "" : list[i].qq) + "</td>" +
                    "<td>" + gname + "</td>" +
                    "<td class='col4'>" + endtime + "<br /></td>" +
                    "<td id='td_" + list[i].id + "'>" + (list[i].state == true ? "正常" : "<font style='color:red'>停用</font>") + "</td>" +
                    "<td><input type=\"hidden\" id=\"" + list[i].id + "\" value=\"" + state + "\" /><a href='a_renewal.aspx?id=" + list[i].id + "'>升级</a> | <a href='javascript:' id=\"btn_" + list[i].id + "\" onclick=\"LockUser('" + list[i].id + "')\">" + (list[i].state == true ? "停用" : "开启") + "</a></td></tr>");
                }
                pager.initPage(page, json.item.itemCount, json.item.pageSize, 5, GetList);
            }, "json");
        }

        function GetDate(time) {
            var date = new Date(time);
            return date.format("yyyy-MM-dd");
        }
        Date.prototype.format = function (format) {
            var o = {
                "M+": this.getMonth() + 1, //month  
                "d+": this.getDate(),    //day  
                "h+": this.getHours(),   //hour  
                "m+": this.getMinutes(), //minute  
                "s+": this.getSeconds(), //second  
                "q+": Math.floor((this.getMonth() + 3) / 3),  //quarter  
                "S": this.getMilliseconds() //millisecond  
            }
            if (/(y+)/.test(format))
                format = format.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
            for (var k in o)
                if (new RegExp("(" + k + ")").test(format))
                    format = format.replace(RegExp.$1, RegExp.$1.length == 1 ? o[k] : ("00" + o[k]).substr(("" + o[k]).length));
            return format;
        }

        //2014-12-20
        function LockUser(UserID) {
            var IsLocked = 0, oldLocked = 0;
            var btn = document.getElementById("btn_" + UserID);
            var td = document.getElementById("td_" + UserID);
            var hid = document.getElementById(UserID);
            if (td == null || btn == null) {
                Alert("页面加载遇到了问题，请刷新后再试");
                return;
            }
            oldLocked = hid.value;
            if (oldLocked == "1") {
                IsLocked = 0;
                if (!confirm("停用账号后，此客户将不能登录使用，确定要停用此账号吗？"))
                    return;
            }
            else if (oldLocked == "0") {
                IsLocked = 1;
                if (!confirm("是否正式开通此账户?"))
                    return;
            }
            else {
                Alert("参数错误");
                return;
            }
            $.post("ajax/agent.ashx?lockuser", { "state": IsLocked, "userid": UserID }, function (data) {
                if (data.code ==0) {
                    if(IsLocked=="1"){
                        btn.innerHTML = "停用";
                        td.innerHTML = "正常";
                    }
                    else {
                        btn.innerHTML = "开启";
                        td.innerHTML = "<font style='color:red'>已停用</font>";
                    }
                    Alert("操作成功");
                }
                else
                    Alert(data.msg);
            }, "json");
        }

    </script>
</head>
<body>
    <!--#include file="uc/top.html" -->
    <div class="content">
        <div class="contenthead">
            <div id="user_ad">
            </div>
        </div>
        <div class="menu0 contentul" id="menu0" style="position: relative">
            <ul>
                <li id="one1" onclick="setTab('one',1,4)" class="hover"><span>客户列表</span></li>
                <li id="one2" style="display: none"><a href="a_list_search.aspx"><span>客户查询</span></a></li>
            </ul>
            <div style="position: absolute; top: 10px; left: 840px;">
                <a href="reg.html?a=<%=user_id%>" target="_blank" class="reg">开通账号</a>
            </div>
        </div>
        <form id="form1" runat="server">
        <div id="con_one_1">
            <div class="query">
                <table id="contentquerytab" class="contentquerytab">
                    <tr>
                        <td style="width: 320px;">
                            <div>
                                客户名称&nbsp;
                                <input type="text" style="width: 186px; height: 32px; vertical-align: middle; padding-left: 2px;
                                    line-height: 30px;" name="siteName" id="siteName" value="<%=siteName %>" />
                            </div>
                        </td>
                        <td style="width: 320px;">
                            <div>
                                &nbsp; 用户名称&nbsp;
                                <input type="text" style="width: 186px; height: 32px; vertical-align: middle; padding-left: 2px;
                                    line-height: 30px;" name="userName" id="userName" value="<%=username %>" />
                            </div>
                        </td>
                        <td style="width: 320px;">
                            <input type="button" id="btn" value="搜 索" style="width: 122px; height: 43px; font-size: 18px;
                                color: White; background-color: #6AC7E8; border: 1px solid #ccc; cursor: pointer;"
                                onclick="GetList(1);" />
                        </td>
                    </tr>
                </table>
            </div>
            <div id="contenttabs">
                <table class="tabs1" cellpadding="4">
                    <tr style="text-align: center">
                        <th style="width: 80px; height: 60px; text-align: center;">
                            编号
                        </th>
                        <th style="height: 60px; text-align: left; padding-left: 10px;">
                            客户信息
                        </th>
                         <th style="width: 150px; height: 60px;">
                            联系方式
                        </th>
                        <th style="width: 120px; height: 60px;">
                            产品版本
                        </th>
                        <th style="width: 120px; height: 60px;">
                            有效期
                        </th>
                        <th style="width: 80px; height: 60px;">
                            状态
                        </th>
                        <th style="width: 80px; height: 60px;">
                            操作
                        </th>
                    </tr>
                    <tbody id="tbody_tab1">
                        <asp:Repeater ID="Repeater1" runat="server">
                            <ItemTemplate>
                                <tr>
                                    <td>
                                        <%# Eval("id")%>
                                    </td>
                                    <td style="line-height: 30px; text-align: left; padding-left: 10px;">
                                        <div class="hleft bold">
                                            <a href="javascript:void(0)">
                                                <%# Eval("nick_name") %></a>/<%# Eval("name") %></div>
                                    </td>
                                    <td>
                                        <%# GroupTitle(Eval("version_id"))%>
                                    </td>
                                    <td>
                                        <%# Eval("date", "{0:yyyy-MM-dd}")%>
                                        <br />
                                        至<br />
                                        <%# Eval("end_date", "{0:yyyy-MM-dd}")%>
                                    </td>
                                    <td style="text-align: center;">
                                        <a href="a_renewal.aspx?id=<%#Eval("id") %>"><span>升级</span></a><br />
                                    </td>
                                </tr>
                            </ItemTemplate>
                        </asp:Repeater>
                    </tbody>
                </table>
                <div class="pager_style">
                    <ul class="page_num">
                    </ul>
                    <ul class="page_info">
                        <li>总数:<span id="count">0</span></li>
                        <li>每页:<span id="pageSize">0</span></li>
                        <li>页数:<span id="pageToal">0</span></li>
                    </ul>
                </div>
            </div>
        </div>
        <div id="con_one_2" style="display: none">
        </div>
        </form>
    </div>
    <!--#include file="uc/Footer_Agent.html" -->
</body>
</html>
